package com.echo.im.server.mq;

import com.echo.im.common.enums.IMCmdType;
import com.echo.im.common.model.IMRecvInfo;
import com.echo.im.common.vo.message.GroupMessageVO;
import com.echo.im.mq.contant.QueueConstants;
import com.echo.im.mq.event.receiver.AbstractMessageReceiver;
import com.echo.im.server.netty.IMServerGroup;
import com.echo.im.server.netty.processor.MessageProcessor;
import com.echo.im.server.netty.processor.factory.ProcessorFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 *
 * @author echo
 * @date 2024-08-13
 */
@Component
@Slf4j
@RequiredArgsConstructor
@DependsOn("IMServerGroup")
public  class GroupPushMessageReceiver extends AbstractMessageReceiver<IMRecvInfo<GroupMessageVO>> {

    private final ProcessorFactory processorFactory;


    @Override
    public void doReceive(IMRecvInfo<GroupMessageVO> data) {
        MessageProcessor<IMRecvInfo<GroupMessageVO>> processor = processorFactory.createProcessor(IMCmdType.GROUP_MESSAGE);
        processor.process(data);
    }

    @Override
    public String getQueueName() {
        return QueueConstants.PUSH_GROUP_QUEUE+"."+IMServerGroup.serverId;
    }
}
